package com.zrsx.searchmodel.service.serviceImpl;

import com.zrsx.searchmodel.common.entity.User;
import com.zrsx.searchmodel.common.vo.UserVO;
import com.zrsx.searchmodel.mapper.CreditScoreMapper;
import com.zrsx.searchmodel.mapper.UserMapper;
import com.zrsx.searchmodel.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private CreditScoreMapper creditScoreMapper;

    @Override
    public UserVO getUserInfo(Integer userId) {
        User user = userMapper.selectById(userId);
        UserVO userVO = new UserVO();
        BeanUtils.copyProperties(user, userVO);
        userVO.setCreditScore(creditScoreMapper.getCreditById(userId));
        userVO.setUpdateTime(LocalDateTime.now());
        return userVO;
    }
}
